import os,sys,re,jsmin

def minify(_str):
	return jsmin.jsmin(_str)

if __name__ == "__main__":
	target = "../static/compressed.js"
       
        files = ["servers.js","chess.js","table.js","piece.js","king.js","square.js","server.js","request.js","user.js"]
        
	source = '\n'.join([ open("../static/%s"%f).read() for f in files ])
	print 'The file has been written to: %s'%(target)
	f = open(target,'w')
        
        source = re.sub("console.log[^\n]+;","",source);
        source = minify(source)

	f.write(source)
	f.close()